package com.yuma.tingshu.account.mapper;

import com.yuma.tingshu.model.account.UserAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

@Mapper
public interface UserAccountMapper extends BaseMapper<UserAccount> {

    // 查询账户余额是否充足
    UserAccount check(@Param("userId") Long userId, @Param("amount") BigDecimal amount);

    // 锁定余额
    int lock(@Param("id") Long id, @Param("amount") BigDecimal amount);

    // 扣减语句
    int minus(@Param("userId") Long userId, @Param("amount") BigDecimal amount);

    // 解锁余额
    int unlock(@Param("userId") Long userId, @Param("amount") BigDecimal amount);

    // 充值
    int plus(@Param("userId") Long userId, @Param("amount") BigDecimal rechargeAmount);
}
